babl: make powf approximation yield 0 for negatives
authorØyvind Kolås <pippin@gimp.org>
Sun, 17 Sep 2017 18:24:16 +0000 (20:24 +0200)
committerØyvind Kolås <pippin@gimp.org>
Sun, 17 Sep 2017 18:24:34 +0000 (20:24 +0200)
babl/babl-trc.c

index 7d9f82f8435f00d9f3eb1e83940cc96508f3d5a8..7524ef8c10961b9beda8ac293cb3b11c4dbf8da1 100644 (file)
@@ -93,10 +93,11 @@ static inline float _babl_trc_gamma_to_linear (const Babl *trc_, float value)
     {
       return babl_polynomial_eval (&trc->poly_gamma_to_linear, value);
     }
-  else
+  else if (value > 0.0f)
     {
       return powf (value, trc->gamma);
     }
+  return 0.0f;
 }
 
 static inline float _babl_trc_gamma_from_linear (const Babl *trc_, float value)
@@ -107,10 +108,11 @@ static inline float _babl_trc_gamma_from_linear (const Babl *trc_, float value)
     {
       return babl_polynomial_eval (&trc->poly_gamma_from_linear, value);
     }
-  else
+  else if (value > 0.0f)
     {
       return powf (value, trc->rgamma);
     }
+  return 0.0f;
 }
 
 static inline void _babl_trc_gamma_to_linear_buf (const Babl *trc_, const float *in, float *out, int in_gap, int out_gap, int components, int count)